package searcher;

import de.schlichtherle.io.File;

/**
 * A listener that is notified when a match occurs between a SearchCriteria and
 * a file. This class enables real time output of matches instead of returning
 * the results when the search has completed.
 * 
 * @version $Id: SearchListener.java,v 1.2 2006/02/23 21:12:15 abutler Exp $
 */
public interface SearchListener
{
	/**
	 * Called when a file is about to be tested by a SearchCriteria
	 * 
	 * @param sc The SearchCriteria testing the file
	 * @param aFile The file to be tested
	 */
	void fileSearched(SearchCriteria sc, File aFile);

	/**
	 * Called when the path of a file matches a SearchCriteria
	 * 
	 * @param sc The SearchCriteria that matched <code>aFile</code>
	 * @param aFile The file that was matched
	 */
	void filePathMatch(SearchCriteria sc, File aFile);

	/**
	 * Called when a portion of text in a file matches a SearchCriteria
	 * 
	 * @param sc The SearchCriteria that matched the text in <code>aFile</code>
	 * @param aFile The file that was matched
	 * @param match A TextMatch containing the position in the file where the
	 *        text match occurred
	 */
	void fileTextMatch(SearchCriteria sc, File aFile, TextMatch match);

	/**
	 * Called when a file, contents and all, matches a SearchCriteria
	 * 
	 * @param sc The SearchCriteria that matched <code>aFile</code>
	 * @param match The FileMatch object describing the match
	 */
	void fileMatch(SearchCriteria sc, FileMatch match);
}
